//{"weight":2}
function extracted() {
    const i2 = setInterval(() => {
        const tempList = document.querySelectorAll(".bili-dyn-list__items>.bili-dyn-list__item");
        if (tempList.length === 0) return;
        clearInterval(i2);
        //调整动态列表的布局方式为类似网格
        Util.addStyle(`
            .bili-dyn-list__items{
           column-count: 2;
            }
            .bili-dyn-list__items>*{
            page-break-inside: avoid;
            }
            `);
    }, 500);
}

(function () {
    'use strict';
    const url = window.location.href;
    const title = document.title;
    Util.addGMMenu("动态首页动态展示双列显示开关", () => {
        const b = confirm("是否开启动态首页动态展示双列显示？\n当前状态:" + (LocalData.isTrendsItemsTwoColumn() === true ? "开" : "关"));
        LocalData.setTrendsItemsTwoColumn(b);
        alert(`已设置状态:${b ? "开" : "关"}`);
    });
    if (!(url.startsWith("https://t.bilibili.com/") && title.startsWith("动态首页-哔哩哔哩"))) {
        return;
    }
    console.log("=========动态首页=========");
    const i1 = setInterval(() => {
        const tab = document.querySelector(".bili-dyn-up-list__content");
        if (tab === null) return;
        clearInterval(i1);
        Trends.setitemsCss();
        Qmsg.success("已修改切换动态用护栏展示");
        $(tab).children(".bili-dyn-up-list__item").click(() => {
            extracted();
        });
    }, 1000);
    Trends.setStyleRichTextarea();
    Trends.topCssDisply.body();
    if (LocalData.isTrendsItemsTwoColumn()) {
        extracted();
    }
    Layout.addMenu();
    $("#isShowMainPanel").click((e) => {
        const target = e.target;
        const aside = $('aside');
        const bodyMain = document.querySelector("main");
        if (target.textContent === "只显示主内容") {
            target.textContent = "显示左右中内容";
            aside.show();
            bodyMain.style.width = "724px";
        } else {
            target.textContent = "只显示主内容";
            aside.hide();
            bodyMain.style.width = "100%";
        }
    });

})();
